//package com.thinksns.sociax.t4.android.event;
//
//import android.graphics.drawable.ColorDrawable;
//import android.os.Bundle;
//import android.widget.ListView;
//
//import com.scwang.smartrefresh.layout.SmartRefreshLayout;
//import com.scwang.smartrefresh.layout.api.RefreshLayout;
//import com.scwang.smartrefresh.layout.listener.OnLoadmoreListener;
//import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
//import com.thinksns.sociax.android.R;
//import com.thinksns.sociax.component.CustomTitle;
//import com.thinksns.sociax.component.LeftAndRightTitle;
//import com.thinksns.sociax.t4.adapter.AdapterEventNotifyCommentList;
//import com.thinksns.sociax.t4.android.Thinksns;
//import com.thinksns.sociax.t4.android.ThinksnsAbscractActivity;
//import com.thinksns.sociax.t4.android.video.ToastUtils;
//import com.thinksns.sociax.t4.model.ModelEventNotifyComment;
//import com.thinksns.sociax.thinksnsbase.network.ApiHttpClient;
//import com.thinksns.sociax.thinksnsbase.utils.UnitSociax;
//
//import java.util.List;
//
///**
// * Created by zhiyicx on 2017/5/8.
// */
//
//public class EventCommentActivity extends ThinksnsAbscractActivity implements OnRefreshListener,OnLoadmoreListener {
//
//    private SmartRefreshLayout smartRefreshLayout;
//    private ListView mListView;
//
//    private int mMinId = 0;
//    private boolean actAlive = true;
//    private AdapterEventNotifyCommentList commentAdapter;
//
//    @Override
//    public String getTitleCenter() {
//        return "活动评论";
//    }
//
//    @Override
//    protected CustomTitle setCustomTitle() {
//        title = new LeftAndRightTitle(this, R.drawable.img_back, "");
//        return title;
//    }
//
//    @Override
//    protected int getLayoutId() {
//        return R.layout.event_comment_activity;
//    }
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        initView();
//        initListener();
//        initData();
//    }
//
//    private void initListener() {
//        smartRefreshLayout.setOnRefreshListener(this);
//        smartRefreshLayout.setOnLoadmoreListener(this);
//    }
//
//    private void initView() {
//        this.smartRefreshLayout = (SmartRefreshLayout) findViewById(R.id.smart_refresh_layout);
//        mListView = (ListView) findViewById(R.id.pull_refresh_list);
//        initListViewAttr();
//    }
//
//    protected void initListViewAttr() {
//        mListView.setDivider(new ColorDrawable(0x72cccccc));
//        mListView.setDividerHeight(UnitSociax.dip2px(this, 0.2f));
//        mListView.setSelector(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
//    }
//
//    private void initData() {
//        commentAdapter = new AdapterEventNotifyCommentList(this, null);
//        mListView.setAdapter(commentAdapter);
//        smartRefreshLayout.autoRefresh();
//    }
//
//    @Override
//    protected void onDestroy() {
//        actAlive = false;
//        super.onDestroy();
//    }
//
//    private void getComment(final int max_id, final boolean isRefresh) {
//        Thinksns.getApplication().getApiEvent().getMyComment("", max_id + "",false, new ApiHttpClient.HttpResponseListener() {
//                    @Override
//                    public void onSuccess(Object result) {
//                        if (actAlive) {
//                            List<ModelEventNotifyComment> modelList = ((ModelExpandComment) result).getComment();
//                            if (modelList.size() > 0) {//取最小comment_id, 作为分页标记
//                                mMinId = modelList.get(modelList.size() - 1).getComment_id();
//                                commentAdapter.setHasData();
//                            }
//                            if (isRefresh) {
//                                commentAdapter.resetData(modelList);
//                            } else {
//                                commentAdapter.addAll(modelList);
//                            }
//                            smartRefreshLayout.finishRefresh();
//                            smartRefreshLayout.finishLoadmore();
//                        }
//                    }
//
//                    @Override
//                    public void onError(Object result) {
//                        if (actAlive) {
//                            smartRefreshLayout.finishRefresh();
//                            smartRefreshLayout.finishLoadmore();
//                            if (!((String) result).equals(R.string.load_fail)) {
//                                if (commentAdapter.getCount() == 0) {
//                                    commentAdapter.setNoData();
//                                }
//                            }
//                        }
//                        ToastUtils.showToast((String) result);
//                    }
//                }
//
//        );
//    }
//
//    @Override
//    public void onLoadmore(RefreshLayout refreshlayout) {
//        getComment(mMinId, false);
//    }
//
//    @Override
//    public void onRefresh(RefreshLayout refreshlayout) {
//        mMinId = 0;
//        getComment(mMinId, true);
//    }
//}
